import { useStore } from 'vuex'
import { useRoute } from 'vue-router'

export function usePermission(permission: string) {
  const store = useStore()
  const route = useRoute()

  const userPermissions: string[] = store.getters['userPermissions']
  const prefix = route.path.slice(1).replace('/', ':') + ':'

  return userPermissions.includes(prefix + permission)
}
